package com.heima.search.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.search.pojos.ApUserSearch;
import com.heima.search.service.HistorySearchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/api/v1/history")
public class HistorySearchController {

    @Autowired
    private HistorySearchService historySearchService;

    /**
     * 加载搜索历史记录
     *
     * @return
     */
    @PostMapping("/load")
    public ResponseResult load(){
        return historySearchService.load();
    }

    /**
     * 删除历史搜索记录
     *
     * @param search
     * @return
     */
    @PostMapping("/del")
    public ResponseResult del(@RequestBody ApUserSearch search){
        log.info("删除历史搜索记录：{}",search);
        return historySearchService.del(search);
    }
}
